#include "gameshowwid.h"
#include "ui_gameshowwid.h"

GameShowWid::GameShowWid(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::GameShowWid)
{
    ui->setupUi(this);
    this->resize(900,900);
}

GameShowWid::~GameShowWid()
{
    delete ui;
}

void GameShowWid::setSocket(shared_ptr<SockClient> client)
{
    m_client=client;

}

bool GameShowWid::eventFilter(QObject *obj, QEvent *evt)
{
   static QPoint mousePoint;
   static bool mousePressed = false;

   QMouseEvent *event = static_cast<QMouseEvent *>(evt);
   if (event->type() == QEvent::MouseButtonPress) {
       if (event->button() == Qt::LeftButton) {
           mousePressed = true;
           mousePoint = event->globalPos() - this->pos();
           return true;
       }
   }
   else if (event->type() == QEvent::MouseButtonRelease) {
       mousePressed = false;
       return true;
   }
   else if (event->type() == QEvent::MouseMove) {
       if (mousePressed && (event->buttons() && Qt::LeftButton)) {
           this->move(event->globalPos() - mousePoint);
           return true;
       }
   }

   return QWidget::eventFilter(obj, evt);
}

void GameShowWid::on_toolButTwoWar_clicked()
{
    ui->widget->twoPeopleWarAct();
}

void GameShowWid::on_toolButAiWar_clicked(bool checked)
{
    ui->widget->aiWarAct();
}

void GameShowWid::on_toolButNetWar_clicked()
{
     ui->widget->netWarAct();
}

void GameShowWid::on_toolButLoad_clicked()
{
     emit rollBackLoading();
}

void GameShowWid::on_toolButWon_clicked()
{
    ui->widget->wonAct();
}

void GameShowWid::on_toolButton_clicked()
{
     ui->widget->timeOutAct();
}
